package app_config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MySQLConfig
	RedisConfig
}

type MySQLConfig struct {
	User     string
	Pwd      string
	Host     string
	Port     int
	Database string
}

type RedisConfig struct {
	Addr string
	Pwd  string
	Db   int
}

var AppConf AppConfig

func Init() {
	viper.SetConfigFile("./app_config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("连接配置文件失败", err)
		return
	}
	viper.Unmarshal(&AppConf)
	fmt.Println("连接配置文件成功")
}
